<template>
  <div>新闻</div>
</template>
<script>
export default {
  data() {
    return {
      age: 18,
    };
  },
  beforeRouteEnter(to, from, next) {
    //这里拿不到this的
    console.log(to);
    console.log(from);
    console.log("路由进入组件之前");
    next((vm) => {
      console.log(vm.age);//通过这个拿到vm相当于this
    });
    // console.log(this.age);
  },
  beforeRouteUpdate() {
    console.log("路由更新组件之前");
  },
  beforeRouteLeave() {
    console.log("路由离开组件之前");
  },
};
</script>